from pymongo import MongoClient
from app.core.config import MONGODB_URI, DATABASE_NAME

client = MongoClient(MONGODB_URI)
db = client[DATABASE_NAME]

class EventCRUD:
    @staticmethod
    async def create_event(event_data):
        return await db.event.insert_one(event_data)

    @staticmethod
    async def get_event_by_id(event_id):
        return await db.event.find_one({'_id': event_id})

    @staticmethod
    async def update_event(event_id, update_data):
        return await db.event.update_one({'_id': event_id}, {'$set': update_data})

    @staticmethod
    async def delete_event(event_id):
        return await db.event.delete_one({'_id': event_id})
